Assignemnt #24 and twenty-first Program
Code
///Name: Derrick Andreasen
///Period: 7
///Program name: Twenty-first Program
///File name: TwefProg.java
///Date Finished:9/22/2015
import java.util.Scanner;
public class TwefProg
{
public static void main( String[] args )
{
String name;
int age, fiveYear, fiveAgo;
Scanner keyboard = new Scanner(System.in);
System.out.print( " Hello. What is your name? " );
name = keyboard.next();
System.out.print( "Hi, " + name + " ! How old are you? " );
age = keyboard.nextInt();
fiveYear = age + 5;
fiveAgo = age - 5;
System.out.println( " Did you know that in five years you will be " + fiveYear + " years old." );
System.out.println( " And five years ago you were " + fiveAgo + "! Imagine that!" );
}
}
Picture of the output